package com.yanqu.road.logic.redis;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.Tuple;

import java.util.HashSet;
import java.util.Set;

/**
==============================================
 *区服创角数
==============================================
* 作者：zrq
* 时间：2023/11/16
**/
public class RedisServerCreateRoleHelper {
    private static Logger logger = LogManager.getLogger(RedisServerCreateRoleHelper.class.getName());

    public static void setRoleCreateCount(long serverId, long count) {
        RedisManger.getRedisUtil().zadd(RedisKeyDefineHelper.getServerRoleCreateCountKey(), count, serverId +"");
    }

    public static Set<Tuple> getRoleCreateCount() {
        Set<Tuple> list = RedisManger.getRedisUtil().zRangeWithScores(RedisKeyDefineHelper.getServerRoleCreateCountKey(), 0, -1);
        if (list == null) {
            return new HashSet<>();
        } else {
            return list;
        }
    }

    public static void setRoleCreateCount2(long serverId, long count) {
        RedisManger.getRedisUtil().zadd(RedisKeyDefineHelper.getServerRoleCreateCount2Key(), count, serverId +"");
    }

    public static Set<Tuple> getRoleCreateCount2() {
        Set<Tuple> list = RedisManger.getRedisUtil().zRangeWithScores(RedisKeyDefineHelper.getServerRoleCreateCount2Key(), 0, -1);
        if (list == null) {
            return new HashSet<>();
        } else {
            return list;
        }
    }
}
